package cn.Alibaba.basic.config;

import cn.Alibaba.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

// 当前类是配置类
@Configuration
public class MyWebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(loginInterceptor).addPathPatterns("/**")
                // 跟登录有关的 注册的都要放行
                .excludePathPatterns("/login/**")
                // 注册相关的
                .excludePathPatterns("/user/*/register","/verifyCode/**","/shop/settlement","/fastDfs","/freemarker/**")
                .excludePathPatterns("/swagger-resources/**", "/webjars/**");

    }
}
